/* 封装本地存储 */
const TokenName = 'yd3-token'
// 存储
export const setStorageToken = (payload) => {
  localStorage.setItem(TokenName, JSON.stringify(payload))
}
// 取
export const getStorageToken = () => {
  return JSON.parse(localStorage.getItem(TokenName)) || {}
}
// 清除token
export const removeStorageToken = () => {
  return localStorage.removeItem(TokenName)
}

/* 封装本地频道存储 */
const channelList = 'channel-list'
// 存储
export const setStoragechannel = (payload) => {
  localStorage.setItem(channelList, JSON.stringify(payload))
}
// 取
export const getStoragechannel = () => {
  return JSON.parse(localStorage.getItem(channelList)) || []
}

/* 封装本地搜索历史记录存储 */
const SearchHistoryList = 'search-list'
// 存储
export const setStorageHistory = (payload) => {
  localStorage.setItem(SearchHistoryList, JSON.stringify(payload))
}
// 取
export const getStorageHistory = () => {
  return JSON.parse(localStorage.getItem(SearchHistoryList)) || []
}
